export function Emoji () {
  return (target: object, key: string) => {
    // target 表示类，key 表示(需要修饰的类中的)属性
    let val = target[key];

    const getter = () => {
      return val;
    }

    const setter = (value: string) => {
      val = `😊 ${value} 😊`;
    }

    Object.defineProperty(target, key, {
      get: getter,
      set: setter,
      enumerable: true,
      configurable: true
    })
  }
}

export function Confirmable (message: string) {
  return (target: Object, key: string, descriptor: PropertyDescriptor) => {
    const original = descriptor.value;  // 要修饰的函数 handleClick
    descriptor.value = (...args: any) => {
      const allow = window.confirm(message);
      if(allow) {
        const result = original.apply(this, args)
        return result
      }
      console.log('不删除')
      return null
    }
    return descriptor
  }
}

